/*
===========================================================================
Copyright (C) 2013-2014 Avotu Briezhaudzetava

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

===========================================================================
*/

#ifndef GUI_PRECURSORS_H
#define GUI_PRECURSORS_H

//
// includes
//
#include <QDialog>
#include "precursormodel.h"
#include "common.h"

//
// namespace: Ui
//
namespace Ui {
class Gui_Precursors;
}

//
// Class: Precursors (gui)
//
class Gui_Precursors : public QDialog {
    Q_CLASSINFO( "description", "Precursor management dialog" )
    Q_OBJECT
    Q_PROPERTY( State currentState READ currentState WRITE toggleWidgetState )
    Q_ENUMS( State )

public:
    explicit Gui_Precursors( QWidget *parent = 0 );
    ~Gui_Precursors();
    enum State {
        NoState = -1,
        Add,
        Edit
    };
    State currentState() const { return this->m_state; }
    Common::Units lastUnits() const { return this->m_lastUnits; }

private slots:
    void on_checkboxSolvent_stateChanged( int );
    void toggleWidgetVisibility( bool visible = true );
    void toggleWidgetState( State state = NoState );
    void on_buttonAdd_clicked();
    void on_buttonEdit_clicked();
    void on_buttonRemove_clicked();
    void readItemState();
    void clearItemState();
    void saveItemState();
    void on_buttonAccept_clicked();
    void on_comboUnits_currentIndexChanged(int index);
    void on_buttonClose_clicked();

private:
    Ui::Gui_Precursors *ui;
    PrecursorModel *listModel;
    State m_state;
    Common::Units m_lastUnits;
};

#endif // GUI_PRECURSORS_H
